const path = require('path')

function resolve(dir) {
    console.log(__dirname)
    return path.join(__dirname, dir)
}

const CompressionPlugin = require('compression-webpack-plugin')

module.exports = {
    publicPath: './',
    outputDir: 'systemManage',
    assetsDir: './',

    chainWebpack: config => {
        config.resolve.alias
            .set('@', resolve('src')) // key,value自行定义，比如.set('@@', resolve('src/components'))
    },

    css: {
        loaderOptions: {
            less: {
                javascriptEnabled: true
            }
        }
    },

    configureWebpack: process.env.NODE_ENV !== 'production' ? {
    } : {
            plugins: [new CompressionPlugin({
                test: /\.js$|\.html$|\.css/,
                threshold: 10240,
                deleteOriginalAssets: false
            })]
        },

    pluginOptions: {
        'moment': {
            locales: [
                'zh-cn'
            ]
        },
        'style-resources-loader': {
            preProcessor: 'less',
            patterns: [path.resolve(__dirname, "src/style/common.less")]
        }
    },

    productionSourceMap: false
}
